#define fexit(s) { fprintf( stderr, "%s\n", s ); exit(1); }
#include <stdio.h>
#include <stdlib.h>
#include "../../jerasure-2.h"

int main( int argc, char** argv )
{
	JER_Matrix *matrix;
	int r = atoi( argv[1] );
	int c = atoi( argv[2] );
	int w = atoi( argv[3] );
	JER_Matrix *matrix2;
	int i, fsize;

	matrix = new JER_Matrix( r, c, w );
	matrix2 = new JER_Matrix( r, c, w );
	if( matrix2 == NULL )
		fexit( "Matrix could not be allocated." );
	srand48(c);
	fsize = 1 << w;
	for( i = 0; i < r * c; i++ )
	{
		matrix->Elts[i/c][i%c] = lrand48() % fsize;
		matrix2->Elts[i/c][i%c] = lrand48() % fsize;
	}
	for( i = 0; i < r; i++ )
		matrix->Elts[i].push_back( matrix2->Elts[i][c/2] );
	matrix->Print();

	return 0;
}
